package com.pd.backend.controller;

import com.pd.backend.dtos.PagePdCoreStationDto;
import com.pd.backend.dtos.PdCoreStationDto;
import com.pd.backend.dtos.ResponseResult;
import com.pd.backend.entity.PdCoreStation;
import com.pd.backend.service.PdCoreStationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 岗位控制层
 * @Auther : 菜鸡编程
 * @Date:2023/1/13
 * @Description:
 * @VERSON:1.8
 */
@RestController
@Slf4j
@RequestMapping(path = "pdCoreStation")
@Api(tags = "岗位管理")
public class PdCoreStationController {

    @Autowired
    private PdCoreStationService pdCoreStationService;

    /**
     * 岗位管理:分页模糊查询
     * @param pagePdCoreStationDto
     * @return
     */
    @ApiOperation("岗位管理:分页模糊查询")
    @GetMapping("/page")
    public ResponseResult PagePdCoreStation(PagePdCoreStationDto pagePdCoreStationDto){
        return pdCoreStationService.PagePdCoreStation(pagePdCoreStationDto);
    }

    /**
     * 新增岗位
     * @return
     */
    @ApiOperation("新增岗位")
    @PostMapping("/add")
    public ResponseResult addPdCoreStation(PdCoreStationDto pdCoreStationDto){
        return pdCoreStationService.addPdCoreStation(pdCoreStationDto);
    }

    /**
     * 根据岗位id修改岗位
     * @return
     */
    @ApiOperation("根据岗位id修改岗位")
    @PutMapping("/update")
    public ResponseResult updateById(PdCoreStation pdCoreStation){
        return pdCoreStationService.updateById(pdCoreStation);
    }

    /**
     * 根据id批量删除岗位
     * @param ids
     * @return
     */
    @ApiOperation("根据id批量删除岗位")
    @DeleteMapping("/delete")
    public ResponseResult deleteByIds(@RequestParam("ids") Long[] ids){
        return pdCoreStationService.deleteByIds(ids);
    }


    /**
     * 根据组织id查询所有岗位
     * @param orgId
     * @return
     */
    @ApiOperation("根据组织id查询所有岗位")
    @GetMapping("/list")
    public ResponseResult listByOrgId(Long orgId){
        return pdCoreStationService.listByOrgId(orgId);
    }


}
